import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

const Index = (resolve)=>{
  import('components/index/index.vue').then((module) => {
    resolve(module)
  })  
}
const Classify = (resolve)=>{
  import('components/classify/classify.vue').then((module) => {
    resolve(module)
  })  
}
const Cart = (resolve)=>{
  import('components/cart/cart.vue').then((module) => {
    resolve(module)
  })  
}
const UserCenter = (resolve)=>{
  import('components/user-center/user-center.vue').then((module) => {
    resolve(module)
  })  
}
const UserLogin = (resolve)=>{
  import('components/user-login/user-login.vue').then((module) => {
    resolve(module)
  })  
}
const UserRegist = (resolve)=>{
  import('components/user-regist/user-regist.vue').then((module) => {
    resolve(module)
  })  
}
const UserRest = (resolve)=>{
  import('components/user-rest/user-rest.vue').then((module) => {
    resolve(module)
  })  
}
const Search = (resolve)=>{
  import('components/search/search.vue').then((module) => {
    resolve(module)
  })  
}
const SearchReault = (resolve)=>{
  import('components/search-result/search-result.vue').then((module) => {
    resolve(module)
  })  
}
const Details = (resolve)=>{
  import('components/details/details.vue').then((module) => {
    resolve(module)
  })  
}
const SecKill = (resolve)=>{
  import('components/seckill/seckill.vue').then((module) => {
    resolve(module)
  })  
}
const BrandSale = (resolve)=>{
  import('components/brand-sale/brand-sale.vue').then((module) => {
    resolve(module)
  })  
}
const GroupShopping = (resolve)=>{
  import('components/group-shopping/group-shopping.vue').then((module) => {
    resolve(module)
  })  
}
const Popularity = (resolve)=>{
  import('components/popularity/popularity.vue').then((module) => {
    resolve(module)
  })  
}
const Settle = (resolve)=>{
  import('components/settle/settle.vue').then((module) => {
    resolve(module)
  })  
}
const AddrList = (resolve)=>{
  import('components/addrlist/addrlist.vue').then((module) => {
    resolve(module)
  })  
}
const Newaddr = (resolve)=>{
  import('components/newaddr/newaddr.vue').then((module) => {
    resolve(module)
  })  
}

export default new Router({
  routes: [
    {
      path: '/',
      redirect: '/index'
    },
    {
      path: '*',
      component: Index
    },
    {
      path: '/index',
      component: Index,
      children: [
        {
          path: ':id',
          component: Details
        }
      ]
    },
    {
      path: '/classify',
      component: Classify
    },
    {
      path: '/cart',
      component: Cart
    },
    {
      path: '/user',
      component: UserCenter,
      children: [
        {
          path: '/user/user-login',
          component: UserLogin
        },
        {
          path: '/user/user-regist',
          component: UserRegist
        },
        {
          path: '/user/user-rest',
          component: UserRest
        }
      ]
    },
    {
      path: '/search',
      component: Search,
      children: [
        {
          path: 'search-result',
          component: SearchReault,
          children: [
            {
              path: ':id',
              component: Details
            }
          ]
        }
      ]
    },
    {
      path: '/seckill',
      component: SecKill
    },
    {
      path: '/brand-sale',
      component: BrandSale
    },
    {
      path: '/group-shopping',
      component: GroupShopping
    },
    {
      path: '/popularity',
      component: Popularity
    },
    {
      path: '/settle',
      component: Settle
    },
    {
      path: '/addrlist',
      component: AddrList,
      children : [
        {
          path: 'newaddr',
          component: Newaddr
        }        
      ]
    }     
  ]
})
